%{
#include <stdlib.h>
#include <string.h>
#include "syntaxe_V4.h"
int numLigne = 1 ;
char * colonne;
int colLu=0;
int nbC;
%}
commentaire %.*
blancs    [ \t]+
chiffre   [0-9]
nombre    {chiffre}+
reel      {nombre}|{nombre}.{nombre}
chaine    [a-zA-Z ]+
tabulation \{[\|][c|l|r|\|]*[\|]\}
%%
"\n"	    {numLigne++;}
{commentaire}  /*On ignore les commentaires*/
{blancs}    /*On ignorer les blancs */
{nombre}    {yylval.ival=atoi(yytext);
	     return (NOMBRE); }
{reel}	    { yylval.fval=atof(yytext);
	     return (REEL); }
{chaine}    { strcpy(yylval.cval,yytext);
		return (CHAINE); }
"\\begin{table}" { return (BTABLE); }
"\\begin{center}" { return (BCENTER); }
"\\begin{tabular}" { return (BTABULAR); }
"\\end{tabular}" { return (ETABULAR); }
"\\end{center}" { return (ECENTER); }
"\\end{table}" { return (ETABLE); }
"\\multicolumn" { return (MULTIC); }
"\\\\" { return (BSBS); }
{tabulation} {if(!colLu){	
			int i=0,j=0;
			int prem=1;
			colonne=malloc(sizeof(char));
			while(yytext[i]!='\0'){
				if(yytext[i]=='c'||yytext[i]=='l'||yytext[i]=='r'){
					if(prem){
						colonne=malloc(sizeof(char));
						*colonne=yytext[i];
						j++;
						prem=0;	
					}else{
						j++;
					 	colonne=realloc(colonne,sizeof(char)*j);
						colonne[j-1]=yytext[i];				
					 }
				}
				i++;
			}
			nbC=j;
			colLu=1;
		}

		 strcpy(yylval.cval,yytext);
		return (TABULATION);}
"\\hline" { return (HLINE);}
"&" { return (EC); }
"{" { return (AO); }
"}" { return (AF); }
"\\" { return (BS); }
"*"  { return (ETOILE);}
","  { return (VIRGULE);}
"$" { return (DOLLAR);}
"\\bf" {return (BF);}
"\\caption" {return (CAPTION);}
%%
